<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>弹出一个提示框</title>
</head>

<body>
    <p>点击按钮查看输入的对话框。</p>
    <button onclick="myFunction()">点我</button>
    <p id="demo"></p>
    <script>
        function myFunction() {
            var x;
            var person = prompt("请输入你的名字", "Harry Potter");
            if (person != null && person != "") {
                x = "你好 " + person + "! 今天感觉如何?";
                document.getElementById("demo").innerHTML = x;
            }
        }
    </script>
</body>

</html>